﻿<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>不合格原因维护</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
    <style>
        .easyui-linkbutton{margin-left:20px;}
        table tr td{padding:0px 5px}
       #fm .l-btn-text{margin-top:3px}
       .tdlabel{text-align:right;padding:5px;}
       .divLabel{padding:10px 0;}
    </style>
</head>
<body>
 <div class="panelSection">    
        <div class="easyui-panel " title="查询区域" style="padding:5px;width:100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
           <form id="searchForm" method="post">
	    	<table>
	    		<tr class="divLabel">
                    <td>原因代码:</td>
                    <td><input  name="REASONCODE" class="easyui-textbox" style="width: 120px; height: 22px"/></td>
                    <td>原因分类:</td>
                    <td><input  name="REASONSORT" class="easyui-textbox" style="width: 120px; height: 22px"/></td>
                    <td>原因细类:</td>
                    <td><input  name="REASONSUBCLASS" class="easyui-textbox" style="width: 120px; height: 22px"/></td>
                    <td><a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.searchData()">查询</a></td>
	    			<td><a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.searchReset()">重置</a></td>
	    		</tr>
	    	</table>
	    </form>
        </div> 
    </div>
    <div class="panelSection">
          <div class="easyui-panel " title="不合格原因详情" style="padding:3px;width:100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
            <table id="UnqualifiedReason" style="height:440px" data-options="rownumbers:true"></table>
            <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                 layout:['first','prev','next','last','manual','info'],              
                    total: 0,
                    showPageList: false,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                     buttons:[{
                            iconCls:'',
                            text:'Go',
                            id:'pageGo'
                    }]
                ">
                    </div>
             <div style="margin-top:7px">
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.createEditUnqualifiedReason(0)">新增</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.createEditUnqualifiedReason(1)">编辑</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.deleteUnqualifiedReason()">删除</a>
              <!--  <form id="fm" method="post" enctype="multipart/form-data" style="display:inline-block;margin-left:20px;">
                    <input class="easyui-filebox" id="fileUpload" name="fileUpload" style="width:68px;height: 24px;line-height: 24px;" data-options="buttonText:'导入模板',onChange:function(n,o){page.easyuiUpload(n,o);}"/>
                </form>-->
             </div>
             </div>
    </div>
    <!-- 创建编辑弹窗-->
    <div id="dd" style="display:none">
         <form id="ceForm" method="post">
	    	<table>
	    		<tr class="divLabel">
                    <td class="tdlabel">唯一代码:</td>
                    <td colspan="3"><input  name="UNIQUECODE" class="easyui-textbox" style="width: 378px;height: 22px;background:#ddd" readonly id="uniqueCode"/></td>
	    		</tr>
                <tr class="divLabel">
                    <td class="tdlabel">原因代码:</td>
                    <td><input  name="REASONCODE" class="easyui-numberbox" style="width: 140px; height: 22px" data-options="onChange:page.ReasonChange" id="REASONCODE"/></td>
                    <td class="tdlabel">原因代码名称:</td>
                    <td><input  name="REASONCODENAME" class="easyui-textbox" style="width: 140px; height: 22px"/></td>
	    		</tr>
                <tr class="divLabel">
                    <td class="tdlabel">原因分类:</td>
                    <td><input  name="REASONSORT" class="easyui-numberbox" style="width: 140px; height: 22px" data-options="onChange:page.ReasonChange" id="REASONSORT"/></td>
	    		</tr>
                 <tr class="divLabel">
                    <td class="tdlabel">原因分类说明:</td>
                    <td colspan="3"><input  name="REASONSORTDES" class="easyui-textbox" style="width: 378px; height: 22px"/></td>
	    		</tr>
                <tr class="divLabel">
                    <td class="tdlabel">原因细类:</td>
                    <td><input  name="REASONSUBCLASS" class="easyui-numberbox" style="width: 140px; height: 22px" data-options="onChange:page.ReasonChange" id="REASONSUBCLASS"/></td>
	    		</tr>
                 <tr class="divLabel">
                    <td class="tdlabel">原因细类说明:</td>
                    <td colspan="3"><input  name="REASONSUBCLASSDES" class="easyui-textbox" style="width: 378px; height: 50px" data-options="multiline:true" /></td>
	    		</tr>
	    	</table>
            <div class="tdlabel" style="margin:10px 20px 0 0">
                    <input type=hidden id="UNQUALIFIEDREASONID" name="UNQUALIFIEDREASONID"/>
                 <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.saveUnqualifiedReason()">确定</a>
                 <a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#dd').dialog('close')">取消</a>
            </div>
            </form>
    </div>
     <!--信息提示区域-->
    <div id="statusMessage" style="font-size: 14px; height: 40px"></div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/json2.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript">
    //创建人：longb
    //日期：2023-11-13
    //描述：排故单附页查看
    var page = {
        pagetotal: 0,
        pageSize: 20,
        pageNumber: 1,
        editIndex:undefined,
        team:null,
        workcenter:null,
        rootPath: getRootPath(), //网站根路径
        ajaxUrl: getRootPath() + "/Ashx/UnqualifiedHandler.ashx",
        //初始化页面
        init: function () {
            page.bind();
            customizedEasyuiPagination('pp'); //定制化分页
        },
       
        //页面事件绑定
        bind: function () {
            $('#UnqualifiedReason').datagrid({
                checkOnSelect: true,
                selectOnCheck: false,
                singleSelect: true,
                rownumbers: true,
                columns: [[
                 { field:'ck',checkbox:true},
                 { field: 'UNIQUECODE', title: '唯一代码', width: 120,align:'center' },
                 { field: 'REASONCODE', title: '原因代码', width: 120 },
		         { field: 'REASONCODENAME', title: '原因代码名称', width: 150 },
                 { field: 'REASONSORT', title: '原因分类', width: 150 },
                 { field: 'REASONSORTDES', title: '原因分类说明', width: 300 },
                 { field: 'REASONSUBCLASS', title: '原因细类', width: 150 },
                 { field: 'REASONSUBCLASSDES', title: '原因细类说明', width: 300 }
                ]],
                onClickRow:function(index,row){
                },
                onLoadSuccess: function (data) {
                    $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: page.pagetotal,
                        pageSize: page.pageSize,
                        pageNumber: page.pageNumber
                    });
                    customizedEasyuiPagination('pp'); //定制化分页
                },
            });
            //分页事件
            $('#pp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    customizedEasyuiPagination('pp'); //定制化分页
                    page.pageSize = pageSize; page.pageNumber = pageNumber;
                    page.getUnqualifiedReason();
                }
            });
            //绑定分页go按钮
            $('#pageGo').on("click", function () {
                var pageNumber = $(this).parents('tr').find('.pagination-num').val();
                page.pageNumber = pageNumber;
                page.getUnqualifiedReason();
            });
        },
        //查询
        searchData: function () {
            clearMessage();
            page.pageNumber = 1;
            page.getUnqualifiedReason();
        },
        //查询重置
        searchReset: function () {
            $('#searchForm').form('clear');
            clearMessage();
        },
        getUnqualifiedReason:function(){
            var frdata = $('#searchForm').serializeArray();
            var data = {};
            $.each(frdata, function () {
                data[this.name] = this.value
            });
            var param = {
                action: "getUnqualifiedReason",
                pageSize: page.pageSize,
                pageNumber: page.pageNumber,
                data: JSON.stringify(data)
            };
            page.post(param, function (res) {
                if (res.Result) {
                    page.pagetotal = res.RowCount;
                    $('#UnqualifiedReason').datagrid('loadData', res.DBTable);
                }
            });
        },
        createEditUnqualifiedReason:function(index){
            if(index==1){
                var row=$('#UnqualifiedReason').datagrid('getChecked');
                if(row.length==0||row.length>1){displayMessage("请选择一行数据再进行操作",false);return;}
                $('#ceForm').form('load',row[0]);
            }else{
                 $('#ceForm').form('clear');
            }

            $('#dd').dialog({
                title: (index==0?'新增':'编辑')+'原因代码',
                width: 500,
                height: 300,
                closed: false,
                cache: false,
                modal: true
            });
        
        },
        saveUnqualifiedReason:function(){
            var frdata = $('#ceForm').serializeArray();
            var data = {};
            $.each(frdata, function () {
                data[this.name] = this.value
            });
            if(data.REASONCODE==""){displayMessage("原因代码不能为空",false);return;}
            if(data.REASONCODENAME==""){displayMessage("原因代码名称不能为空",false);return;}
            if(data.REASONSORT==""){displayMessage("原因分类不能为空",false);return;}
            if(data.REASONSORTDES==""){displayMessage("原因分类说明不能为空",false);return;}
            if(data.REASONSUBCLASS==""){displayMessage("原因细类不能为空",false);return;}
            if(data.REASONSUBCLASSDES==""){displayMessage("原因细类说明不能为空",false);return;}
            var param={
                action:'saveUnqualifiedReason',
                data:JSON.stringify(data)
            }

            page.post(param, function (res) {
                if (res.Result) {
                   $('#dd').dialog('close');
                   $('#ceForm').form('clear');
                   page.getUnqualifiedReason();
                }
                 displayMessage(res.Message, res.Result);
            });
        },
        deleteUnqualifiedReason:function(){
            var rows=$('#UnqualifiedReason').datagrid('getChecked');
            if(rows.length==0){displayMessage('请选择至少一条信息再进行操作',false);return;}
            page.post({action:'deleteUnqualifiedReason',data:JSON.stringify(rows)}, function (res) {
                 if(res.Result){
                    page.getUnqualifiedReason();
                 }
                 displayMessage(res.Message, res.Result);
            })
        },
        ReasonChange:function(n,o){
            var uniqueCode="";
            var REASONCODE=$('#REASONCODE').textbox('getValue');
            var REASONSORT=$('#REASONSORT').textbox('getValue');
            var REASONSUBCLASS=$('#REASONSUBCLASS').textbox('getValue');
            if(REASONCODE!=""){uniqueCode+=REASONCODE;}
            if(REASONSORT!=""){uniqueCode+='-'+REASONSORT;}
            if(REASONSUBCLASS!=""){uniqueCode+='-'+REASONSUBCLASS;}
            $('#uniqueCode').textbox('setValue',uniqueCode);
        },
        easyuiUpload: function (n,o) {
            if(o!=""){return;}
            if ($('#fileUpload').filebox('getValue') != "") {
                clearMessage();
                $('#fm').form('submit', {
                    url: page.ajaxUrl + "?action=ImportAssemWorkFlowTemplate",
                    onSubmit: function () {
                        return $(this).form('validate');
                    },
                    success: function (result) {
                        $('#fileUpload').filebox('clear');
                        var res = JSON.parse(result); 
                        if(res.Result){page.getTemlateData();}
                        displayMessage(res.Message, res.Result);
                    }
                });
            }
        },
        //post数据
        post: function (param, callback) {
            $.ajax({
                type: "Post",
                url: page.ajaxUrl,
                data: param,
                cashe: false,
                async: true,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                }
            });
        },
        postasync: function (param, callback) {
            $.ajax({
                type: "Post",
                url: page.ajaxUrl,
                data: param,
                cashe: false,
                async: true,
                dataType: "json",
                beforeSend: function () {
                    //$.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                }
            });
        }
    }
    $(function () {
        page.init();
    });
</script>
